
$(document).ready(function(){
	var id=getvl("id");
	if(id!=null && id!=""){
			getGoodsDetail(id);
	}

});

function getGoodsDetail(id){
	  $.ajax({  
        type : "GET",  
        url : urlcore + "/api/goods/goodsDetails?goodsId="+id, //图片上传出来的url，返回的是图片上传后的路径，http格式  
        dataType : "json",
        headers:{"Content-Type":"application/json;charset=UTF-8"},
        data : {},
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	var da=data.data[0];
        	if(data.success==true){
        		var goodsType="";
        	goodsType=da.goodsType==1?"骑手商城":"商家商城";
            $("#title").html(da.goods.title);
            //处理规格和日期
            var marketPrices = " ";
            var unitStandards = " ";        
            for (var i = 0; i < data.data.length; i++){
            	marketPrices += data.data[i].marketPrice+","; 
            	unitStandards += data.data[i].unitStandard+",";            	 
            }
            marketPrices=(marketPrices.substring(marketPrices.length-1)==',')?marketPrices.substring(0,marketPrices.length-1):marketPrices;
           	unitStandards=(unitStandards.substring(unitStandards.length-1)==',')?unitStandards.substring(0,unitStandards.length-1):unitStandards;
           	
        	$("#marketPrice").html(marketPrices);
            $("#unitStandard").html(unitStandards);
        	$("#goodsType").html(goodsType);//商品类型
        	    var goodsUrl = da.goods.goodsUrl,imgStr1="";
                    if (goodsUrl != null && goodsUrl != '') {
                        goodsUrl= goodsUrl.split("***");
                        $.each(goodsUrl,function(index,value){
                            imgStr1 += 
                            	'<div style="position:relative;width:250px;height:250px;float:left;" display="block">'+
                            	'	<span onclick="removeStrHtml(this)" style="position:absolute;top:10px;right:10px;font-size:20px;color:#f00;" class="glyphicon glyphicon-trash" aria-hidden="true">'+
                            	'	</span>'+
                            	'	<img style="padding: 5px 5px 5px 5px;" width="250px" height="250px" src="'+value+'">'+
                        		'</div>';
                        });
                    }
                    $('#goodsUrl').html(imgStr1);
            $('#goodsDetail').html(da.goods.goodsDetail);
        	}else {
                alert(data.msg);
            }
        },
        error:function(){  
            alert("失败");  
        }  
    });
	
}








